package com.qf.account;

import java.text.ParseException;
import java.text.SimpleDateFormat;

/**
 * @author wangyu
 * @Classname: DateUtils
 * @Description: TEST
 * @date 2022-04-06 14:52
 */
public class DateUtils {
    private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    //    1字符串转换为until.Date
    public static java.util.Date strToUtil(String str) {
        try {
            java.util.Date date = sdf.parse(str);
            return date;
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }

    //    2 until.Date 转换为sql.Date
    public static java.sql.Date utiToSql(java.util.Date date) {
        return new java.sql.Date(date.getTime());
    }

    //    3 until.Date转换为字符串
    public static String utiToStr(java.util.Date date) {
        return sdf.format(date);
    }

}
